import 'package:dynamic_forms/dynamic_forms.dart';
import 'package:meta/meta.dart';

class DyCheckBox extends FormElement {
  static const String titlePropertyName = "title";
  static const String valuePropertyName = "value";
  static const String attributePropertyName = "attribute";

  String get title => properties[titlePropertyName].value;
  Stream<String> get titleChanged => properties[titlePropertyName].valueChanged;
  bool get value => properties[valuePropertyName].value;
  Stream<bool> get valueChanged => properties[valuePropertyName].valueChanged;
  String get attribute => properties[attributePropertyName].value;
  Stream<String> get attributeChanged =>
      properties[attributePropertyName].valueChanged;

  void fillCheckBox(
      {@required String id,
      @required ElementValue<FormElement> parent,
      @required ElementValue<bool> isVisible,
      @required ElementValue<String> attribute,
      @required ElementValue<String> title,
      @required ElementValue<bool> value}) {
    fillFormElement(id: id, parent: parent, isVisible: isVisible);
    registerElementValue(titlePropertyName, title);
    registerElementValue(valuePropertyName, value);
    registerElementValue(attributePropertyName, attribute);
  }

  @override
  FormElement getInstance() {
    return DyCheckBox();
  }
}
